package com.homework.module6part2.controller;

import com.homework.dao.domain.Job;
import com.homework.dao.domain.User;
import com.homework.module6part2.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.support.HttpRequestHandlerServlet;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.net.http.HttpResponse;
import java.util.List;

@Controller
public class JobListController {

    @Autowired
    protected JobService jobService;

    @RequestMapping("/job/list")
    public ModelAndView list(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("job_list");
        modelAndView.addObject("list", jobService.jobList());

        User user = (User) request.getSession().getAttribute("session_user");
        modelAndView.addObject("user", user);

        return modelAndView;
    }
}
